home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr47 / wasm223.zip / PARMS.ASM < prev    next >
Assembly Source File  |  1993-05-04  |  2KB  |  88 lines

  1. ;**************************************;
  2. ; WASM Parameter Module                ;
  3. ; By Eric Tauck                        ;
  4. ;                                      ;
  5. ; Defines:                             ;
  6. ;                                      ;
  7. ;   ParRes  reset the parameter reader ;
  8. ;   ParGet  get the next parameter     ;
  9. ;**************************************;
  10.  
  11.         call    ParRes          ;reset parameters
  12.         jmps    _parms_end
  13.  
  14. ;--- data
  15.  
  16. _par_next       DW      ?       ;address of next parameter
  17. _par_bytes      DB      ?       ;bytes left in line
  18.  
  19. ;========================================
  20. ; Find non-delimiter.
  21. ;
  22. ; In: BX= pointer; CX= byte count.
  23. ;
  24. ; Out: BX,CX= updated; CY= set if not
  25. ;      found.
  26.  
  27. _par_skipdel PROC NEAR
  28.         jcxz    _prskp2         ;exit if no bytes left
  29. _prskp1 cmp     BYTE [bx], ' '  ;check if space or control character
  30.         ja      _prskp3         ;exit loop if not
  31.         inc     bx              ;next character
  32.         loop    _prskp1         ;loop
  33. _prskp2 stc
  34.         ret
  35. _prskp3 clc
  36.         ret
  37.         ENDP
  38.  
  39. ;========================================
  40. ; Find a delimiter.
  41. ;
  42. ; In: BX= pointer; CX= byte count.
  43. ;
  44. ; Out: BX,CX= updated.
  45.  
  46. _par_finddel PROC NEAR
  47. _prfin1 cmp     BYTE [bx], ' '  ;check if space or control character
  48.         jbe     _prfin2         ;exit loop if not
  49.         inc     bx              ;next character
  50.         loop    _prfin1         ;decrement count
  51. _prfin2 ret
  52.         ENDP
  53.  
  54. ;========================================
  55. ; Reset the parameter pointer so the
  56. ; first parameter is returned next.
  57.  
  58. ParRes  PROC   NEAR
  59.         mov     _par_next, 81H  ;save address
  60.         mov     al, [80H]
  61.         mov     _par_bytes, al  ;save bytes
  62.         ret
  63.         ENDP
  64.  
  65. ;========================================
  66. ; Return address of next parameter.
  67. ;
  68. ; Out: AX= address of next parameter; CY=
  69. ;      set if no parameter returned.
  70.  
  71. ParGet  PROC   NEAR
  72.         mov     bx, _par_next
  73.         mov     cl, _par_bytes
  74.         sub     ch, ch
  75.         call    _par_skipdel    ;skip delimiters
  76.         jc      _prget1
  77.         push    bx
  78.         call    _par_finddel    ;find delimter
  79.         mov     BYTE [bx], 0    ;store terminator
  80.         mov     _par_next, bx   ;save address
  81.         mov     _par_bytes, cl  ;save bytes left
  82.         pop     ax
  83.         clc
  84. _prget1 ret
  85.         ENDP
  86.  
  87. _parms_end
  88.